<template>
  <div class="head-container">
    <!-- 搜索 -->
    <el-input v-model="query.groupNo" clearable placeholder="团购编号" style="width: 200px;" class="filter-item" @keyup.enter.native="toQuery"/>
    <el-select v-model="query.orderStatus" placeholder="状态" style="width: 200px;" @change="changeType">
      <el-option
        v-for="(item, i) in orderStatusArr"
        :key="i"
        :label="item.name"
        :value="item.status"/>
    </el-select>
    <el-date-picker
      v-model="query.orderBeginDate"
      type="date"
      format="yyyy-MM-dd"
      value-format="yyyy-MM-dd"
      clearable
      placeholder="开始日期"
      style="width: 200px;"
      class="filter-item" 
      @keyup.enter.native="toQuery"/>
    <el-date-picker
      v-model="query.orderEndDate"
      type="date"
      format="yyyy-MM-dd"
      value-format="yyyy-MM-dd"
      clearable
      placeholder="开始日期"
      style="width: 200px;"
      class="filter-item" 
      @keyup.enter.native="toQuery"/>
    <el-button class="filter-item" size="mini" type="primary" icon="el-icon-search" @click="toQuery">搜索</el-button>
    <el-button class="filter-item" size="mini" type="primary" @click="handleExportExcel">导出Excel</el-button>
  </div>
</template>

<script>
import checkPermission from '@/utils/permission'
import eForm from './form'
export default {
  components: { eForm },
  props: {
    query: {
      type: Object,
      required: true
    }
  },
  data() {
    return {
      downloadLoading: false,
      companyType: "",
      orderStatusArr: [
        {
          status: "0",
          name: "团购中"
        },
        {
          status: "1",
          name: "团购完成"
        },
        {
          status: "2",
          name: "团购失效"
        }
      ]
    }
  },
  methods: {
    checkPermission,
    toQuery() {
      console.log(this.query)
      this.$parent.page = 0
      this.$parent.init()
    },
    changeType(e) {
      this.query.orderStatus = e
      // this.toQuery()
    },
    handleExportExcel() {
      const url = `https://jinfang.xunyu.shop/admin/order/export?buylerName=${this.query.buylerName || ''}&compNo=${this.query.compNo || ''}&confirmDateBegin=${this.query.confirmDateBegin || ''}&confirmDateEnd=${this.query.confirmDateEnd || ''}&orderDateBegin=${this.query.orderBeginDate || ''}&orderDateEnd=${this.query.orderEndDate || ''}&orderNo=${this.query.orderNo || ''}&orderStatus=${this.query.orderStatus || ''}&pageNum=0&pageSize=0&recvPhone=${this.query.recvPhone || ''}`
      window.open(url)
    }
  }
}
</script>
